<template>
  <div class="wait-handle">
    <a-drawer
      title="售后单详情"
      :width="drawerWidth"
      :visible="isShowDrawer"
      @close="onClose"
    >
    <div class="wait-handle-container">
      <div class="order-top">
        <img src="../../../../assets/image/sellerHub/after_bg.png" alt="">
        <span>售后编号：{{saleDetailList.afterSaleNo}}</span>
        <span class="dangban"></span>
        <span>订单编号：{{saleDetailList.subOrderId}}</span>
        <img src="../../../../assets/image/sellerHub/copy.png" alt="">
        <span class="dangban"></span>
        <span>申请日期：{{$dateTrans(saleDetailList.applyTime).format('yyyy-MM-dd hh:mm:ss')}}</span>
        <span class="dangban"></span>
        <span>{{saleDetailList.tenantName}}</span>
        <span class="order-top-right">
          <img src="../../../../assets/image/sellerHub/reject.png" alt="">
          <span>驳回</span>
        </span>
      </div>
      <div class="order-card-bg"></div>
      <div class="order-bg">
        <ul class="order-nav">
          <li>责任判定：<span class="responsibility">{{saleDetailList.duty=='PLATFORM'?'平台责任':saleDetailList.duty=='FOUR_SERVICE'?'4s店责任':'承运商责任'}}</span></li>
          <li>具体说明：<span class="error-msg">{{saleDetailList.detailDTOS[1].reason || '--'}}</span></li>
          <li>协商处理方案：<span class="order-msg">同意买家退货退款</span></li>
        </ul>
        <div class="line-gray">
          <div class="line-red" :style="redLine"></div>
          <ul class="line-spot">
            <li><img v-if="steps > 0" src="../../../../assets/image/sellerHub/checked.png" alt=""><span v-else>1</span></li>
            <li style="margin-left:50%"><img v-if="steps > 1" src="../../../../assets/image/sellerHub/checked.png" alt=""><span v-else>2</span></li>
            <li style="margin-left:100%"><img v-if="steps > 2" src="../../../../assets/image/sellerHub/checked.png" alt=""><span v-else>3</span></li>
          </ul>
          <ul class="spot-msg">
            <li>
              <p :class="steps > 0?'spot-success':''">服务网点售后申请</p>
              <p>2021-12-12 12:12:00</p>
            </li>
            <li style="margin-left:50%">
              <p :class="steps > 1?'spot-success':''">4S店确认售后</p>
              <p>2021-12-12 12:12:00</p>
            </li>
            <li style="margin-left:100%">
              <p :class="steps > 2?'spot-success':''">退款成功</p>
              <p>2021-12-12 12:12:00</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="dividing-line"></div>
    <div class="wait-handle-goods">
      <p class="order-title">售后商品</p>
    <a-row type="flex" class="table-title" style="color: #272424;">
        <a-col :span="7" class="textOverflow" style="text-align:left;padding-left:12px;">
          商品
        </a-col>
        <a-col :span="3" class="textOverflow">
          单价(元)
        </a-col>
        <a-col :span="3" class="textOverflow">
          金额(元)/数量
        </a-col>
        <a-col :span="3" class="textOverflow">
          售后金额(元)
        </a-col>
        <a-col :span="8" class="textOverflow" style="text-align:left;padding-left:12px;">
          售后信息
        </a-col>
      </a-row>
      <div class="table-items" style="color: #272424;">
        <div class="item-container">
          <a-row type="flex">
            <a-col :span="7" class="textOverflow">
              <div class="order-table-name vertical-middle" style="text-align:left;">
                <img class="dinghuo" src="../../../../assets/image/sellerHub/dinghuo.png" alt="">
                <img src="../../../../assets/image/sellerHub/price.png" alt="">
                <div class="table-name-right">
                  <div class="right-item">
                    <span>机油</span>
                    <em>|</em>
                    <i class="textOverflow" >零件号:2010521215</i>
                  </div>
                  <div class="right-item textOverflow">
                    <span class="item-label">规格：</span>
                    <span>1651654165456</span>
                    </div>
                </div>
              </div>
            </a-col>
            <a-col :span="3" class="textOverflow">
               <div class="vertical-middle">
                <p>2,700.00</p>
              </div>
            </a-col>
            <a-col :span="3" class="textOverflow" style="text-align:right;">
              <div class="vertical-middle">
                <p style="margin-right:13px;">2000.00</p>
                <p style="margin-right:13px;">1件</p>
              </div>
            </a-col>
            <a-col :span="3" class="textOverflow border-right border-left">
              <div class="vertical-middle">
                <p>2,700.00</p>
              </div>
            </a-col>
            <a-col :span="8">
              <div style="text-align:left;">
                <div class="msg-left">
                  <p><span>申请类型：</span><span>退款</span></p>
                  <p><span>配件情况：</span><span>未安装</span></p>
                  <p><span>收货外包装：</span><span>包装完好</span></p>
                  <p><span>收货原因：</span><span>配件质量问题</span></p>
                  <p><span>售后说明：</span><span>货物运输过程中损坏，无法使用，故退款。</span></p>
                </div>
                <div class="msg-right">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                  <img src="../../../../assets/image/sellerHub/price.png" alt="">
                </div>
              </div>
            </a-col>
          </a-row>
        </div>
      </div>
      <p></p>
    </div>
    <p class="order-price">售后总数：<span>2</span></p>
    <br/>
    <p class="order-price">退款金额：<span>￥22,000</span></p>
    <div class="dividing-line" style="margin-top:44px;"></div>
    <div class="consult-record">
      <p class="record-title">协商记录</p>
      <div class="record-container">
        <p v-for="(item,i) in saleLogList" :key="i">
          <img v-if="item.operateSource=='FOUR_SERVICE'" src="../../../../assets/image/sellerHub/business.png" alt="">
          <img v-if="item.operateSource=='PLATFORM'" src="../../../../assets/image/sellerHub/platform.png" alt="">
          <img v-if="item.operateSource=='TWO_SERVICE'" src="../../../../assets/image/sellerHub/buyers.png" alt="">
          <span>{{item.operateSource | operateSourceFilter}}</span>
          <span>{{item.operateName}}</span>
        </p>
      </div>
    </div>
    <div class="none"></div>
    <!-- <div class="cancel-order">
      <div @click="agreeBtn" class="agree-btn">同意</div>
      <div @click="rejectBtn" class="reject-btn">驳回</div>
    </div> -->
    </a-drawer>
  </div>
</template>
<script>
import Vue from 'vue'
import {Drawer} from 'ant-design-vue'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import Pagination from '@/components/common/pagination'
Vue.use(Drawer)
//历史价格table配置

export default {
  model: {
    prop: 'isShowDrawer',
    event: 'change'
  },
  props: {
    isShowDrawer: Boolean,
    afterSaleId: String,
  },
  components:{Pagination},
  data() {
    return {
      drawerWidth: window.innerWidth*0.8,
      locale: zhCN,
      active:0,//选中项
      steps: 2,//步骤
      redLine:'width:50%',//步骤条
      saleLogList: [],//协商记录列表
      saleDetailList: {},//售后详情
    }
  },
  computed: {
    stockHistory() {
      
    },
  },
  filters: {
    operateSourceFilter(_val) {
      let _msg = '';
      _val=='TWO_SERVICE'?_msg='买家':
      _val=='PLATFORM'?_msg='平台':
      _val=='FOUR_SERVICE'?_msg='4S店（商家）':'';
      return _msg;
    }
  },
  watch: {
    isShowDrawer() {
      this.init();
    },
    steps(_val) {
      let _width = 0;
      switch(_val) {
        case 0:
          _width = 0;
          break;
        case 1:
          _width = 0;
          break;
        case 2:
          _width = 50;
          break;
        case 3:
          _width = 100;
          break; 
      }
      this.redLine = `width:${_width}%`;
    }
  },
  created() {
    
  },
  methods: {
    init() {
      //获取数据
      this.$store.dispatch('request', this.$api.sellerCenter.getAfterSaleDetailId(
        this.afterSaleId
      )).then(res => {
        console.log(res,'res')
        this.saleDetailList = res.result;
      }).catch(() => {
        this.$message.error('')
      })
      //协商记录
      this.$store.dispatch('request', this.$api.sellerCenter.getAfterSaleLogAfterSakeId(
        this.afterSaleId
      )).then(res => {
        this.saleLogList = res.result;
      }).catch(() => {
        this.$message.error('')
      })
    },
    // agreeBtn() {
    //   this.steps = 1;
    // },
    // rejectBtn() {
    //   this.steps = 2;
    // },
    onClose() {
      this.$emit('change',false)
    },
    checkNavList(i) {
      //选择库存状态
      this.active = i;
    },
  },
}
</script>
<style lang="less">
.ant-drawer-body {
  padding: 0;
}
.bottom-pagination-card>.paginationBefore {
    float: right;
    line-height: 70px;
    i {
      color: @activeRed;
    }
  }
.bottom-pagination-card {
  position: fixed;
  bottom: 0;
  width: 80%;
  background: #fff;
  right: 0;
  box-shadow: 0px -2px 2px 0px rgba(39,36,36,0.02); 
  padding-right: 30px;
}

.wait-handle-container {
  padding: 12px;
  position: relative;
  .order-top {
    background: url('../../../../assets/image/sellerHub/order_bg.png') no-repeat center top;
    background-size: 100% 100%;
    width: 100%;
    height: 112px;
    position: relative;
    z-index: 2;
    background-clip: content-box;
    padding-bottom: 7px;
    line-height: 80px;
    font-size: 12px;
    span {
      vertical-align: middle;
    }
    img:nth-of-type(1) {
      width: 24px;
      margin-left: 24px;
      margin-right: 8px;
    }
    img:nth-of-type(2) {
      width: 16px;
      margin-left: 8px;
    }
    .order-top-right {
      float: right;
      margin-right: 64px;
      font-size: 20px;
      font-weight: 600;
      color: @activeRed;
      img {
        width: 50px;
      }
    }
    .dangban {
      margin:0 16px;
      height: 12px;
      display: inline-block;
      width: 1px;
      background: #ebedf2;
    }
  }
  .order-card-bg {
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    font-size: 12px;
    width: calc(100% - 11px);
    height: 138px;
    box-shadow: 0px 0px 6px 1px rgba(39,36,36,0.06); 
    margin-top: -8px;
  }
  .order-bg {
    width: 93.57%;
    position: absolute;
    top: 103px;
    z-index: 3;
    left: 36px;
    .order-nav {
      overflow: hidden;
      background: #fafafa;
      width: 100%;
      height: 52px;
      font-size: 12px;
      color: rgba(39,36,36,0.6);
      li {
        float: left;
        height: 52px;
        line-height: 52px;
        width: 33.33%;
        padding-left: 16px;
      }
      span {
        margin-left: 8px;
      }
      .error-msg {
        color: #272424;
      }
      .order-msg {
        color: #79c860;
      }
      .responsibility {
        display: inline-block;
        width: 104px;
        height: 34px;
        background: url('../../../../assets/image/sellerHub/goods_bg.png') no-repeat center top;
        background-size: 100% 100%;
        font-size: 14px;
        color: @activeRed;
        font-weight: 600;
        padding: 0 22px;
        position: absolute;
        top: 11px;
        line-height: 30px;
      }
    }
    .line-gray {
      width: 88.25%;
      height: 2px;
      background: rgba(39,36,36,0.08);
      position: absolute;
      bottom: -26px;
      left: 59px;
      .line-spot>li {
        background: #fff;
        overflow: hidden;
        width: 20px;
        height: 20px;
        position: absolute;
        top: -10px;
        img {
          width: 20px;
          height: 20px;
          position: absolute;
          z-index: 8;
        }
        span {
          position: absolute;
          width: 20px;
          height: 20px;
          display: inline-block;
          border-radius: 100%;
          line-height: 20px;
          text-align: center;
          background: #eeeeee;
          color: #fff;
        }
      }
      .spot-msg {
        position: absolute;
        top: 18px;
        width: 100%;
        font-size: 12px;
        color: rgba(39,36,36,0.6);
        li {
          text-align: center;
          float: left;
          width: 20%;
          transform: translate(-46%,0);
          position: absolute;
          .spot-success {
            color: rgba(39,36,36,1);
          }
        }
      }
    }
    .line-red {
      background: rgba(215,55,55,1);
      width: 37.5%;
      height: 2px;
      position: absolute;
      left: 0;
    }
  }
}
.dividing-line {
  width: 100%;
  height: 16px;
  background: #f8f8f8;
  margin: 12px 0 0;
}
.item-container {
  min-height: 92px;
  padding: 16px 0;
  margin-bottom: 16px;
  border: 1px solid rgba(39,36,36,0.08);
  border-radius: 0 0 2px 2px;
  font-size: 12px;
  .msg-left {
    padding-left: 12px;
    color: rgba(39,36,36,1);
    width: calc(100% - 145px);
    p {
      overflow: hidden;
      margin-bottom: 6px;
    }
    span:first-child {
      display: inline-block;
      color: rgba(39,36,36,0.6);
      position: absolute;
      left: 12px;
    }
    span:last-child {
      margin-left: 72px;
      display: inline-block;
    }
    P:first-child {
      span:last-child {
        color: @activeRed;
      }
    }
  }
  .msg-right {
    position: absolute;
    right: 16px;
    width: 130px;
    top: 0px;
    overflow-y: scroll;
    height: 100%;
    img {
      width: 60px;
      height: 60px;
      margin-bottom: 10px;
    }
    img:nth-child(odd) {
      margin-right: 10px;
    }
  }
  .msg-right::-webkit-scrollbar {
    display: none;
  }
}
.wait-handle-goods {
  padding: 24px;
  .order-title {
    font-size: 14px;
    font-weight: 600;
    color: #272424;
    border-left: 4px solid @activeRed;
    display: inline-block;
    height: 16px;
    line-height: 16px;
    padding-left: 8px;
  }
}
.order-price {
  width: 210px;
  float: right;
  margin-right: 24px;
  margin-top: -8px;
  span {
    float: right;
  }
}
.order-price:nth-of-type(1) {
  font-size: 12px;
  color: rgba(39,36,36,0.6);
}
.order-price:nth-of-type(2) {
  color: rgba(39,36,36,1);
  line-height: 27px;
  margin-bottom: 16px;
  span {
    font-size: 18px;
    color: @activeRed;
  }
}
.none {
  height: 100px;
  width: 100%;
}
.cancel-order {
  position: fixed;
  width: 80%;
  background: #fff;
  bottom: 0;
  right: 0;
  height: 56px;
  box-shadow: 0px -2px 2px 0px rgba(39,36,36,0.02); 
  .agree-btn,.reject-btn {
    width: 128px;
    height: 56px;
    float: right;
    text-align: center;
    background: #f8f8f8;
    color: #272424;
    line-height: 56px;
    cursor: pointer;
  }
  .agree-btn {
    background: @activeRed;
    color: #fff;
  }
}
.border-right {
  border-right: 1px solid rgba(39,36,36,0.06);
}
.border-left {
  border-left: 1px solid rgba(39,36,36,0.06);
}
.consult-record {
  padding: 24px;
  .record-title {
    font-size: 14px;
    font-weight: 600;
    color: #272424;
    border-left: 4px solid @activeRed;
    display: inline-block;
    height: 16px;
    line-height: 16px;
    padding-left: 8px;
  }
  .record-container {
    width: 100%;
    background: #fafafa;
    border-radius: 2px;
    font-size: 12px;
    padding:0 24px;
    color: rgba(39,36,36,1);
    margin-top: 16PX;
    img {
      width: 16px;
      height: 16px;
    }
    span {
      vertical-align: middle;
      display: inline-block;
    }
    span:nth-of-type(1) {
      color: rgba(39,36,36,0.6);
      margin: 0 16px 0 8px;

    }
    p {
      height: 48px;
      line-height: 48px;
      border-bottom: 1px solid #f2f2f2;
    }
    p:last-child {
      border: none;
    }
  }
}
</style>